﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SurfaceApplication1
{
    public class WindowsView 
    {
        #region Fields

        private TextBox textbox;

        #region TextBox Methods
        public void updateTextboxField(string text)
        {
            textbox.Text = text;
        }
        public string readTextBoxField()
        {
            return textbox.Text;
        }
        #endregion
        
        private ListBox listbox;

        #region ListBox Methods

        public void updateListboxField(List<String> fieldItems )
        {
            if(fieldItems!=null)
                foreach (string s in fieldItems)
                {
                    ListBoxItem item = new ListBoxItem();
                    item.Content= s;
                    item.ContentStringFormat = s;
                    listbox.Items.Add(item);
                }
        }

        public string readListBoxField(int index)
        {
            if (listbox != null && index<listbox.Items.Count)
                return listbox.Items[index].ToString();
            return "";
        }

        public string readListBoxSelectedField()
        {
            return ((ListBoxItem)listbox.SelectedItem).ContentStringFormat;
        }
        #endregion
        
        private Image imageField;

        #region Image Methods
        public void updateImageField(string file)
        {
            imageField.Source = new BitmapImage(new Uri(file));
        }
        public string readImageSourceField()
        {
            return imageField.Source.ToString();
        }
        public double readImageHeightField()
        {
            return imageField.Height;
        }
        public double readImageWidthField()
        {
            return imageField.Width;
        }
        public void updateImageSize(double width, double height)
        {
            imageField.Width = width;
            imageField.Height = height;
        }
        #endregion
        
        private Slider sliderField;
       
        #region Slider Methods

        public double readSliderValueField()
        {
            return sliderField.Value;
        }

        #endregion

        #endregion

        #region Constructor
        public WindowsView(WpfApplication1.Window1  windows)
        {
            this.textbox = windows.textBox1;
            this.listbox = windows.listBox1;
            this.sliderField = windows.slider1;
            this.imageField = windows.image1;
        }
        #endregion

    }

  }
